The main purpose of this template is to produce a set of quick diagnostic plots you can use during the early stages of model development to get a quick look at how your model fits the data. This template will only create an html preview of some typical diagnostic plots. It will read in covariates of interest from your spec file but it will not attempt to rename your ETAs or save out any plots.
These plots are not intended to be report quality - please use the diagnostics-report.Rmd template to create diagnostics suitable for your report.
Please remember that these plots are just meant to provide a quick look at your model diagnostics. They are not an exhaustive list of every possible plot and were chosen with this projects aims in mind.
While this should give users examples of plots generated with the most up-to-date packages and methods, we’re always happy to have feedback. If you know of more efficient methods or want to suggest alternative ways of plotting the figures please open an issue with the details.
── Status ─────────────────────────────────
• Finished Running
── Absolute Model Path ───────────────────────────
• /data/home/ryanm/bbr-nonmem-poppk-foce/model/pk/106
── YAML & Model Files ───────────────────────────
• /data/home/ryanm/bbr-nonmem-poppk-foce/model/pk/106.yaml
• /data/home/ryanm/bbr-nonmem-poppk-foce/model/pk/106.ctl
── Description ───────────────────────────────
• Final Model
── Tags ──────────────────────────────────
• two-compartment + absorption
• ETA-CL
• ETA-KA
• ETA-V2
• CLWT-allo
• V2WT-allo
• QWT-allo
• V3WT-allo
• CLEGFR
• CLAGE
• CLALB
• proportional RUV
── Notes ──────────────────────────────────
• 1: Client was interested in adding Albumin to CL
Dataset: ../../../data/derived/analysis3.csv
Records: 4292 Observations: 3142 Subjects: 160
Objective Function Value (final est. method): 30904.409
Estimation Method(s):
– First Order Conditional Estimation with Interaction
No Heuristic Problems Detected
| parameter_names | estimate | stderr | shrinkage |
|---|---|---|---|
| THETA1 | 0.443 | 0.0643 | |
| THETA2 | 4.12 | 0.0275 | |
| THETA3 | 1.17 | 0.0280 | |
| THETA4 | 4.21 | 0.0190 | |
| THETA5 | 1.28 | 0.0348 | |
| THETA6 | 0.485 | 0.0395 | |
| THETA7 | -0.0378 | 0.0635 | |
| THETA8 | 0.419 | 0.0863 | |
| OMEGA(1,1) | 0.219 | 0.0526 | 14.4 |
| OMEGA(2,2) | 0.0824 | 0.00981 | 5.51 |
| OMEGA(3,3) | 0.114 | 0.0128 | 1.25 |
| SIGMA(1,1) | 0.0399 | 0.00123 | 5.02 |
The covariates can be defined in several ways, please use whichever you find most convenient:
Please note that the order described above will be preserved so, if for example, you choose to define the covariates with flags in your yspec, you can over ride these choices by passing in a specific set of covariates when rendering the Rmd. Both option 1 and 2 would override the choice of covariates listed in the code below.
Read in the model details using read_model. Details
stored in the mod object can be used to identify the
location of the source data (used in $DATA) - to see how this is done
look at the bbr::get_data_path() and
bbr::build_path_from_model() helper functions.
After reading in the nonmem dataset and the output dataset they’re
joined by a NUM column. This assumes that a row
number column (called NUM) was included during data
assembly. The idea here is that in NONMEM, you table just
NUM and none of the other input data items. They all will
get joined back to the nonmem output … even character columns.
The data used in the diagnostic plots has been filtered
to only include the observations (i.e. EVID==0). Note that
further modifications maybe needed, for example, if BLQ data was
included in the model or if the DV was log-transformed. The
dataset also converts the categorical covariates of interest to factors
using the yspec_add_factors function and details described
in the spec file.
The id subset gets the first record per ID. This would
usually be the baseline value but consider filtering on a baseline flag
if available. Also, if the model includes inter-occassion variaibility
(IOV), the occassion variable should be included within the
distinct function.
The following plots assume that the preferred x-axis labels are defined here.
Create plots of DV vs PRED and IPRED for the full dataset
NPDE vs PRED, time and time after dose.
NPDE vs continuous covariates
## $AGE
##
## $WT
##
## $ALB
##
## $EGFR
NPDE vs categorical covariates.
## $STUDY
##
## $RF
##
## $CP
##
## $DOSE
Note that here we use a function that maps over the ETAs (not the covariates) because the purpose of these plots was to determine whether there were any trends in the covariates for a given ETA. This may need to be edited to address different study specific questions.
## [[1]]
##
## [[2]]
Note that here we use a function that maps over the covariates (not the ETAs) because the purpose of these plots was to determine whether there is any difference in the distribution of ETAs across studies, dosing groups and disease states. This should be updated to reflect the questions you’re trying to address.
## $STUDY
##
## $RF
##
## $CP
##
## $DOSE
It is considered good practice to include these details at the end of all rmd scripts
Sys.getenv("AMI_NAME")
## [1] "metworx-22.09-20220915120953-e92bea3c"
sessioninfo::session_info()
## ─ Session info ───────────────────────────────────────────────────────────────
## setting value
## version R version 4.1.3 (2022-03-10)
## os Ubuntu 18.04.6 LTS
## system x86_64, linux-gnu
## ui X11
## language (EN)
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz America/New_York
## date 2023-10-13
## pandoc 2.17.1.1 @ /usr/lib/rstudio-server/bin/quarto/bin/ (via rmarkdown)
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date (UTC) lib source
## assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.1.3)
## backports 1.4.1 2021-12-13 [1] CRAN (R 4.1.3)
## bbr * 1.7.0 2023-10-12 [1] MPNDEV (R 4.1.3)
## bit 4.0.5 2022-11-15 [1] CRAN (R 4.1.3)
## bit64 4.0.5 2020-08-30 [1] CRAN (R 4.1.3)
## bslib 0.5.1 2023-08-11 [1] CRAN (R 4.1.3)
## cachem 1.0.8 2023-05-01 [1] CRAN (R 4.1.3)
## checkmate 2.2.0 2023-04-27 [1] CRAN (R 4.1.3)
## cli 3.6.1 2023-03-23 [1] CRAN (R 4.1.3)
## colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.1.3)
## crayon 1.5.2 2022-09-29 [1] CRAN (R 4.1.3)
## data.table 1.14.8 2023-02-17 [1] CRAN (R 4.1.3)
## diffobj 0.3.5 2021-10-05 [1] CRAN (R 4.1.3)
## digest 0.6.33 2023-07-07 [1] CRAN (R 4.1.3)
## dplyr * 1.1.3 2023-09-03 [1] CRAN (R 4.1.3)
## evaluate 0.21 2023-05-05 [1] CRAN (R 4.1.3)
## fansi 1.0.4 2023-01-22 [1] CRAN (R 4.1.3)
## farver 2.1.1 2022-07-06 [1] CRAN (R 4.1.3)
## fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.1.3)
## forcats * 1.0.0 2023-01-29 [1] CRAN (R 4.1.3)
## fs 1.6.3 2023-07-20 [1] CRAN (R 4.1.3)
## generics 0.1.3 2022-07-05 [1] CRAN (R 4.1.3)
## GGally 2.1.2 2021-06-21 [1] CRAN (R 4.1.3)
## ggplot2 * 3.4.3 2023-08-14 [1] CRAN (R 4.1.3)
## glue * 1.6.2 2022-02-24 [1] CRAN (R 4.1.3)
## gridExtra 2.3 2017-09-09 [1] CRAN (R 4.1.3)
## gridGraphics 0.5-1 2020-12-13 [1] CRAN (R 4.1.3)
## gtable 0.3.4 2023-08-21 [1] CRAN (R 4.1.3)
## here * 1.0.1 2020-12-13 [1] CRAN (R 4.1.3)
## hms 1.1.3 2023-03-21 [1] CRAN (R 4.1.3)
## htmltools 0.5.6 2023-08-10 [1] CRAN (R 4.1.3)
## jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.1.3)
## jsonlite 1.8.7 2023-06-29 [1] CRAN (R 4.1.3)
## knitr * 1.44 2023-09-11 [1] CRAN (R 4.1.3)
## labeling 0.4.3 2023-08-29 [1] CRAN (R 4.1.3)
## lattice 0.21-8 2023-04-05 [1] CRAN (R 4.1.3)
## lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.1.3)
## lubridate * 1.9.2 2023-02-10 [1] CRAN (R 4.1.3)
## magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.1.3)
## Matrix 1.6-1.1 2023-09-18 [1] CRAN (R 4.1.3)
## mgcv 1.9-0 2023-07-11 [1] CRAN (R 4.1.3)
## mrggsave * 0.4.5 2023-10-12 [1] MPNDEV (R 4.1.3)
## mrgmisc * 0.1.5 2023-10-12 [1] MPNDEV (R 4.1.3)
## munsell 0.5.0 2018-06-12 [1] CRAN (R 4.1.3)
## nlme 3.1-163 2023-08-09 [1] CRAN (R 4.1.3)
## patchwork * 1.1.3 2023-08-14 [1] CRAN (R 4.1.3)
## pillar 1.9.0 2023-03-22 [1] CRAN (R 4.1.3)
## pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.3)
## plyr 1.8.8 2022-11-11 [1] CRAN (R 4.1.3)
## pmplots * 0.3.7 2023-10-12 [1] MPNDEV (R 4.1.3)
## pmtables * 0.6.0 2023-10-12 [1] MPNDEV (R 4.1.3)
## processx 3.8.2 2023-06-30 [1] CRAN (R 4.1.3)
## ps 1.7.5 2023-04-18 [1] CRAN (R 4.1.3)
## purrr * 1.0.2 2023-08-10 [1] CRAN (R 4.1.3)
## R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.3)
## RColorBrewer 1.1-3 2022-04-03 [1] CRAN (R 4.1.3)
## Rcpp 1.0.11 2023-07-06 [1] CRAN (R 4.1.3)
## readr * 2.1.4 2023-02-10 [1] CRAN (R 4.1.3)
## renv 1.0.3 2023-09-19 [1] CRAN (R 4.1.3)
## reshape 0.8.9 2022-04-12 [1] CRAN (R 4.1.3)
## rlang 1.1.1 2023-04-28 [1] CRAN (R 4.1.3)
## rmarkdown * 2.25 2023-09-18 [1] CRAN (R 4.1.3)
## rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.1.3)
## rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.1.3)
## sass 0.4.7 2023-07-15 [1] CRAN (R 4.1.3)
## scales 1.2.1 2022-08-20 [1] CRAN (R 4.1.3)
## sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.3)
## stringi 1.7.12 2023-01-11 [1] CRAN (R 4.1.3)
## stringr * 1.5.0 2022-12-02 [1] CRAN (R 4.1.3)
## tibble * 3.2.1 2023-03-20 [1] CRAN (R 4.1.3)
## tidyr * 1.3.0 2023-01-24 [1] CRAN (R 4.1.3)
## tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.1.3)
## tidyverse * 2.0.0 2023-02-22 [1] CRAN (R 4.1.3)
## timechange 0.2.0 2023-01-11 [1] CRAN (R 4.1.3)
## tzdb 0.4.0 2023-05-12 [1] CRAN (R 4.1.3)
## utf8 1.2.3 2023-01-31 [1] CRAN (R 4.1.3)
## vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.1.3)
## vroom 1.6.3 2023-04-28 [1] CRAN (R 4.1.3)
## withr 2.5.0 2022-03-03 [1] CRAN (R 4.1.3)
## xfun 0.40 2023-08-09 [1] CRAN (R 4.1.3)
## xtable 1.8-4 2019-04-21 [1] CRAN (R 4.1.3)
## yaml * 2.3.7 2023-01-23 [1] CRAN (R 4.1.3)
## yspec * 0.6.1 2023-10-12 [1] MPNDEV (R 4.1.3)
##
## [1] /data/home/ryanm/bbr-nonmem-poppk-foce/renv/library/R-4.1/x86_64-pc-linux-gnu
## [2] /data/home/ryanm/.cache/R/renv/sandbox/R-4.1/x86_64-pc-linux-gnu/dbd573bd
##
## ──────────────────────────────────────────────────────────────────────────────
bbr::bbi_version()
## [1] "3.3.0"